package com.ruoyi.web.controller.wb;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wb.domain.WbClassify;
import com.ruoyi.wb.service.IWbClassifyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 维保类目列Controller
 *
 * @author ruoyi
 * @date 2024-10-14
 */

@Api(tags="维保类目列管理")
@RestController
@RequestMapping("/wb/wbClassify")
public class WbClassifyController extends BaseController {
    @Autowired
    private IWbClassifyService wbClassifyService;

    /**
     * 查询维保类目列列表
     */
    @ApiOperation("查询维保类目列列表")
    @GetMapping("/list")
    public TableDataInfo list(WbClassify wbClassify) {
        startPage();
        List<WbClassify> list = wbClassifyService.selectWbClassifyList(wbClassify);
        return getDataTable(list);
    }

    /**
     * 导出维保类目列列表
     */
    @ApiOperation("导出维保类目列列表")
    @Log(title = "维保类目列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbClassify wbClassify) {
        List<WbClassify> list = wbClassifyService.selectWbClassifyList(wbClassify);
        ExcelUtil<WbClassify> util = new ExcelUtil<WbClassify>(WbClassify.class);
        util.exportExcel(response, list, "维保类目列数据");
    }

    /**
     * 获取维保类目列详细信息
     */
    @ApiOperation("获取维保类目列详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(wbClassifyService.selectWbClassifyById(id));
    }

    /**
     * 新增维保类目列
     */
    @ApiOperation("新增维保类目列")
    @Log(title = "维保类目列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbClassify wbClassify) {
        return toAjax(wbClassifyService.insertWbClassify(wbClassify));
    }

    /**
     * 修改维保类目列
     */
    @ApiOperation("修改维保类目列")
    @Log(title = "维保类目列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbClassify wbClassify) {
        return toAjax(wbClassifyService.updateWbClassify(wbClassify));
    }

    /**
     * 删除维保类目列
     */
    @ApiOperation("删除维保类目列")
    @Log(title = "维保类目列", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(wbClassifyService.deleteWbClassifyByIds(ids));
    }

    @ApiOperation("查询维保类目列列表")
    @GetMapping("/selectList")
    public TableDataInfo selectList(WbClassify wbClassify) {
        List<WbClassify> list = wbClassifyService.selectWbClassifyList(wbClassify);
        return getDataTable(list);
    }
}